:header
call %working_dir%\header.cmd

REM 4-Drivers.bat
REM This installs various drivers to your PE Image. Edit this accordingly to include SCSI,
REM SATA, NIC, and other drivers.
REM Syntax is "Dism /image:DRIVE:\Temp\Mount /Add-Driver /driver:DRIVE:FOLDER\*.inf"

:WAIK
REM Change DIR to Windows AIK
cd "%waik%\Servicing\"

:Main Menu
ECHO -------------------------------------
ECHO            Driver Menu
ECHO -------------------------------------
ECHO.
ECHO 1. Inject Drivers to WIM file
ECHO 2. View 3rd Party Drivers
ECHO 3. View All drivers in WIM file
ECHO Q. Quit to Main Menu
ECHO.
ECHO.

REM ========== Choice Logic ============
choice /c:123q /n /m "%choice_text%"
if errorlevel 4 goto :end
if errorlevel 3 goto :showall
if errorlevel 2 goto :3rd party
if errorlevel 1 goto :start

:start
ECHO.
ECHO This will inject drivers found in the subfolders of your driver parent folder
ECHO This does a search for .inf files
ECHO.
ECHO Type in the path of your drivers
ECHO Default is %drivers_PE%
ECHO.
REM clear our %drivers_dir%
set drivers_dir=
Echo Enclose path with double quotes if there is a space in the path
Echo.
set /p drivers_dir=Drivers Path: 
if '%drivers_dir%'=='' set drivers_dir=%drivers_PE%
ECHO.
ECHO Setting Driver Directory to %drivers_dir%
goto :inject

:inject
ECHO Injecting the drivers into the image
ECHO Please be patient this may take awhile......
ECHO.
DISM /image:"%MOUNTPATH%" /Add-Driver /driver:%drivers_dir% /recurse
echo.
echo The drivers have now been injected into your Wim image.
ECHO.
ECHO Press a key to return to Driver Menu
pause > nul
goto :header

:3rd party
call %working_dir%header.cmd
echo 3rd party driver list - Exporting to %wim_dest%\3rd_party_drivers.txt
Dism /image:%MOUNTPATH% /Get-Drivers > %wim_dest%\3rd_party_drivers.txt
start %wim_dest%\3rd_party_drivers.txt
ECHO.
ECHO Press a key to return to Driver Menu
pause > nul
goto :header

:showall
call %working_dir%header.cmd
echo All drivers - Exporting to %wim_dest%\all_drivers.txt
Dism /image:%MOUNTPATH% /Get-Drivers /all > %wim_dest%\all_drivers.txt
start %wim_dest%\all_drivers.txt
ECHO.
ECHO Press a key to return to Driver Menu
pause > nul
goto :header

:end
call %working_dir%\end.cmd